#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 30;
typedef struct 
{
	int id;
    string piao;
}S;
S s[N];
int n;
int cmp(S a, S b)
{
	if (a.piao.size() != b.piao.size()) {
		return a.piao.size() > b.piao.size();
	}
	else {
		int m = a.piao.size();
		for (int i = 0; i < m; i++) {
			if (a.piao[i] != b.piao[i]) {
				return a.piao[i] > b.piao[i];
			}
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		s[i].id = i + 1;
		string a;
		cin >> a;
		s[i].piao = a;
	}
	sort(s, s + n, cmp);
	cout << s[0].id << endl << s[0].piao << endl;
	return 0;
}